#ifndef __TIMER_H__
#define __TIMER_H__

#include "base/object.h"
#include <windows.h>

namespace MiniUI
{

class Timer : public Object,
              public Creator<Timer>
{
public:
    friend class Creator<Timer>;
protected:
    Timer();
    ~Timer();
public:
    UINT GetTimerID() const;
    void Start(UINT nID);   //start with custom id
    void Start();
    void Stop();
    void SetInterval(uint nInterval);
    typedef void (*TIMERCALLBACK)(void);
private:
    void DoTimer();
    static void CALLBACK TimerProc(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
public:
    Event<OnNotifyEventFunc> OnTimer;
private:
    uint m_nInterval;
    UINT_PTR m_nID;
    UINT m_customID;
    bool m_bStoped;
};

class TimerWnd
{
public:
    TimerWnd();
    ~TimerWnd();
public:
    HWND GetHandle();
private:
    static LRESULT CALLBACK TimerWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
private:
    HWND m_hWnd;
};

}

#endif